from google.appengine.ext import db

class LocalUsers(db.Model):
    displayName = db.StringProperty(required = True)
    user = db.UserProperty()
    isAuthorized = db.BooleanProperty()
    joinDate = db.DateProperty(auto_now_add = True)


class FabricType(db.Model):
    localUser = db.ReferenceProperty(LocalUsers)
    displayName = db.StringProperty(required = True)
    defaultSalePrice = db.FloatProperty()
    defaultBuyPrice = db.FloatProperty()
    addDate = db.DateTimeProperty(auto_now_add = True)
    
class Statistic(db.Model):
    localUser = db.ReferenceProperty(LocalUsers)
    fabricType = db.ReferenceProperty(FabricType)
    meter = db.FloatProperty()
    price = db.FloatProperty()
    type = db.StringProperty(choices=('in', 'out'))
    addDate = db.DateTimeProperty(auto_now_add = True)
